package pers.qianyu.month_202101.date_20210110;

/**
 * 137. 只出现一次的数字 II
 * https://leetcode-cn.com/problems/single-number-ii/
 *
 * @author mizzle rain
 * @date 2021-01-10 11:51
 */
public class SingleNumber {
    public int singleNumber(int[] nums) {
        int res = 0;
        for (int i = 0; i < 32; i++) {
            int count = 0;
            for (int num : nums) {
                count += (num >> i) & 1;
            }
            if (count % 3 == 1) {
                res += 1 << i;
            }
        }
        return res;
    }
}
